package com.zlf.config;

import feign.Response;
import feign.codec.ErrorDecoder;
import jdk.nashorn.internal.runtime.regexp.joni.exception.InternalException;
import org.springframework.context.annotation.Configuration;

/**
 * @Description Feign 自定义 ErrorDecoder (捕获 Feign 服务端异常)
 */
@Configuration
public class FeignErrorDecoderConfig implements ErrorDecoder {

    @Override
    public Exception decode(String s, Response response) {
        System.out.println("异常信息：" + s);
        System.out.println(response.body());
        return new InternalException("系统异常，请联系管理员");
    }
}
